/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.intec.matsab.dao;

import edu.intec.matsab.persistence.Pensum;
import edu.intec.matsab.persistence.PersistenceManager;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceException;
import javax.persistence.Query;

/**
 *
 * @author matilde
 */
public class PensumDAO extends BasicoDAO{

    public static List<Pensum> buscar(String idCarrera)
    {
        EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
        EntityManager manager = emf.createEntityManager();

        List<Pensum> listPensum = new ArrayList<Pensum>();

        try {
            Query query = manager.createNamedQuery("Pensum.findByIdCarrera");
            query.setParameter("idCarrera", idCarrera);
            listPensum = (List<Pensum>) query.getResultList();

        } catch (PersistenceException exception) {
            exception.printStackTrace();
        } finally {
            manager.close();
        }

        return listPensum;
    }
}
